package org.tea.springdata.jpa.domain;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * @Author: 张廷
 * @Description: User实体
 * @Date: 2012-6-29
 * @Time: 下午12:48:26
 */
@Entity
@Table( name = "spring_data_user" )
@PrimaryKeyJoinColumn( name = "id" )
@NamedQueries({
//	@NamedQuery(name = "findSingleById", query = "SELECT * FROM User u WHERE u.id=?1"),
	@NamedQuery(name = "findAllUserWithName", 
				query = "SELECT u FROM User u WHERE u.name LIKE :name")
})
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class User extends IdGenerator{

	private static final long serialVersionUID = 1L;
	
	private String name;
	private String username;
	private String password;
	private String sex;
	private Date birth;
	private String address;
	private String zip;
	
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getZip() {
		return zip;
	}

	public void setZip(String zip) {
		this.zip = zip;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}
	
	@Temporal(TemporalType.DATE)
	public Date getBirth() {
		return birth;
	}

	public void setBirth(Date birth) {
		this.birth = birth;
	}

}
